$(function () {
    var $search = parseSearch(), arg = {}, tag = '';
    console.log($search);
    function operRes(res) {
        if (res.code == 200) {
            fnSuccess('操作成功');
            search({}, true);
        } else {
            fnFail(res.error || '操作失败');
        }
    }

    var diff = {
        baner: { // 主题
            query: '/category/list?type1=banner',//分页查询URL,
            rendered: function () {
                if ($search.type == 'theme' && $search.pcId) {//拼场主题
                    $('.delete').hide();// 禁止删除
                    if (!$('.bread-last-child').length) {
                        $('.breadcrumb').append('<li class="bread-last-child">\"' + decodeURIComponent($search.name) + '\"拼场主题</li>')
                    }
                }
            },
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加Banner",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '跳转URL',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入跳转URL',
                                        name: 'remark'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'banner'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改Banner",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: $json.desc1,
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '跳转URL',
                                        val: $json.remark || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入跳转URL',
                                        name: 'remark'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    form.type1 = 'banner'; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: 'Banner图',
                    class_: 'upload',
                    onClick: function () {
                        var $json = $(this).data('json');
                        uploadFn('Banner图', {
                            w: 400,
                            h: 400,
                            num: 12,
                            labelNum: '12 upload-custom-label',
                            noCrop: false,
                            preview: 'left-top-preview'
                        }, function (data) {
                            closeLayer(data.layerIndex);
                            $.post('/category/update', {id: $json.id, url: data.path}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('上传成功～')
                                } else {
                                    fnFail(res.error || '上传失败！')
                                }
                            })
                            console.log(data);
                        });
                        // window.location.href = './img.html?id=' + $json.id + '&type=theme'
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },

                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=banner', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                search({}, true);
                            }
                        })
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[4]);
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
                enableBtn(btns[4], $item);
            },
            fields: [
                {name: 'name', label: '标题', enableSearch: true},
                {
                    name: 'desc1', label: '描述', filter: function (item) {
                    return viewMore(item.desc1 || ''); // 预览更多内容
                }
                },
                {
                    name: 'url', label: '跳转URL', filter: function (item) {
                    if (item.remark) {
                        return '<a target="_blank" href="' + item.remark + '" title="点击预览">' + item.remark + '</a>'
                    } else {
                        return getDefaultImgStr();
                    }
                }
                },
                {
                    name: 'isShow', label: '上架状态',
                    filter: function (item) {
                        return item.isShow == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"
                    },
                },
                {name: 'orderNum', label: '排序号'},
                {
                    name: 'url', label: 'Banner图',
                    filter: function (item) {
                        if (item.url) {
                            return '<a target="_blank" href="' + item.url + '" title="点击预览"><img style="height:60px;border-radius: 5px" src="' + item.url + '"></a>'
                        } else {
                            return getDefaultImgStr();
                        }
                    },
                }
            ],
        },
        'kepu-article-category': { //
            query: '/category/list?type1=kepu-article-category',//分页查询URL,
            rendered: function () {
            },
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加Banner",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },

                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'kepu-article-category'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改Banner",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: $json.desc1,
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },

                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    form.type1 = 'banner'; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },

                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=banner', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                search({}, true);
                            }
                        })
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
            },
            fields: [
                {name: 'name', label: '标题', enableSearch: true},
                {
                    name: 'desc1', label: '描述', filter: function (item) {
                    return viewMore(item.desc1 || ''); // 预览更多内容
                }
                },

                {
                    name: 'isShow', label: '上架状态',
                    filter: function (item) {
                        return item.isShow == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"
                    },
                },
                {name: 'orderNum', label: '排序号'},

            ],
        },
        'days-manager': { //
            query: '/category/list?type1=days-manager-'+$search.targetId,//分页查询URL,
            rendered: function () {
            },
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加成长天数",
                                data: [
                                    {
                                        type: 'text',
                                        label: '成长值',
                                        require: true, // 是否必填
                                        placeholder: '请输入成长值(成长范围用1:10表示第1到第10天)',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'days-manager-'+$search.targetId; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        var $index = dialogForm(
                            {
                                title: "修改成长天数",
                                data: [
                                    {
                                        type: 'text',
                                        label: '成长值',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入成长值(成长范围用1:10表示第1到第10天)',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },

                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=days-manager-'+$search.targetId, 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                search({}, true);
                            }
                        });
                    }
                },
                {
                    label: '上传形态图',
                    class_: 'upload',
                    onClick: function () {
                        var $json = $(this).data('json');
                        uploadFn('形态图', {
                            w: 500,
                            h: 500,
                            num: 12,
                            labelNum: '12 upload-custom-label',
                            noCrop: false,
                            preview: 'left-top-preview'
                        }, function (data) {
                            closeLayer(data.layerIndex);
                            $.post('/category/update', {id: $json.id, url: data.path}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('上传成功～')
                                } else {
                                    fnFail(res.error || '上传失败！')
                                }
                            })
                            console.log(data);
                        });
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[4]);
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[4], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
            },
            fields: [
                {name: 'name', label: '标题', enableSearch: true},
                {
                    name: 'url', label: '形态图', filter: function (item) {
                    if (item.url) {
                        return '<a target="_blank" href="' + item.url + '" title="点击预览"><img style="height:60px;border-radius: 5px" src="' + item.url + '"></a>'
                    } else {
                        return getDefaultImgStr();
                    }
                },
                },

                {
                    name: 'isShow', label: '上架状态',
                    filter: function (item) {
                        return item.isShow == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"
                    },
                },
                {name: 'orderNum', label: '排序号'},

            ],
        },
        'kepu-video-category': { //
            query: '/category/list?type1=kepu-video-category',//分页查询URL,
            rendered: function () {
            },
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加视频分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },

                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'kepu-video-category'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改视频分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '标题',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入标题',
                                        name: 'name'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '描述',
                                        val: $json.desc1,
                                        require: true, // 是否必填
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },

                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },

                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=kepu-video-category', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                search({}, true);
                            }
                        })
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
            },
            fields: [
                {name: 'name', label: '标题', enableSearch: true},
                {
                    name: 'desc1', label: '描述', filter: function (item) {
                    return viewMore(item.desc1 || ''); // 预览更多内容
                }
                },

                {
                    name: 'isShow', label: '上架状态',
                    filter: function (item) {
                        return item.isShow == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"
                    },
                },
                {name: 'orderNum', label: '排序号'},

            ],
        },
        order: { // 订单管理
            query: '/order/query',//分页查
            rendered: function () {

            },
            fields: [
                {name: '', label: '活动标题'},
                {
                    name: 'desc1', label: '描述', filter: function (item) {
                    return viewMore(item.desc1 || ''); // 预览更多内容
                }
                },
                {name: 'orderNum', label: '排序号'},

            ],
        },
        category: { // 商品分类管理
            query: '/category/list?type1=shop-category&size=' + maxSize,//分页查询URL,
            tag: '分类管理',
            dateSearch: false,
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '分类名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入分类名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },

                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'shop-category'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        if ($json.name == '批量上货导入') {
                            return alert('批量上货导入不能修改')
                        }
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改商品分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '分类名称',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入分类名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        val: $json.desc1 || '',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum || 0,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        if ($json.name == '批量上货导入') {
                            return alert('批量上货导入不能删除')
                        }
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '增加二级分类',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        console.log($json);
                        var $json = {};
                        if ($jon.level == 2) {
                            $json = $jon;
                        }
                        var $index = dialogForm(
                            {
                                title: "增加二级分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '二级分类',
                                        val: $json.name || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入二级分类',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        val: $json.desc1 || '',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号' || 0,
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                full: true,
                                submit: function (form) {
                                    form.level = 2;
                                    form.type1 = 'shop-category';
                                    if ($jon.level == 1) { //  为一级菜单增加子菜单
                                        form.pId = $jon.id;
                                    } else { // 修改子菜单
                                        form.id = $jon.id; // 数据类型菜单
                                    }
                                    //form.type1 = 'front-menu'; // 数据类型菜单
                                    $.post($jon.level == 1 ? '/category/add' : '/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        if ($jon.name == '批量上货导入') {
                            return alert('批量上货导入不能上架')
                        }
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=shop-category', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                fnSuccess(($jon.isShow == '1' ? '上架' : '下架') + '操作成功')
                                search({}, true);
                            }
                        })
                    }
                },
                {
                    label: '移动',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        if ($jon.level == 2) {
                            $json = $jon;
                        }
                        var $index = dialogForm(
                            {
                                title: "移动",
                                data: [
                                    {
                                        type: 'text',
                                        label: '移动至',
                                        val: $json.name || '',
                                        require: true, // 是否必填
                                        placeholder: '请选择一级目录',
                                        name: 'pId'
                                    },
                                ],
                                full: true,
                                shown: function () {
                                    selectGoods({
                                        name: 'pId',
                                        url: '/category/list?type1=shop-category&level=1',
                                        selected: $json.pId,
                                        key: 'KEY' + Math.random()
                                    })
                                },
                                submit: function (form) {
                                    //$json.pId = form.pId;
                                    form.id = $json.id;
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("移动操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("移动操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '树形结构查看',
                    onClick: function () {
                        window.location.href = '../setting/category.html'
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[5]);
                disableBtn(btns[4]);
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[4], $item);
                if ($item.level == '2') {
                    enableBtn(btns[5], $item);
                }
                if ($item.level == 1 && $item.type1 == 'shop-category') {
                    enableBtn(btns[3], $item);
                }
            },
            listFilter: function (res) {
                console.log(res);
                var t = _.filter(res, function (itme) {
                    return itme.level == 1;
                })
                var tg = _.filter(res, function (itme) {
                    return itme.level == 2;
                });
                tg = _.groupBy(tg, 'pId');
                t = _.sortBy(t, 'orderNum').reverse();
                t1 = [];
                t.map(function (item) {
                    t1.push(item);
                    if (tg[item.id]) { //
                        t1.push(_.sortBy(tg[item.id], 'orderNum').reverse())
                    }
                })
                return _.flatten(t1, true);
            },
            fields: [
                {
                    name: 'name', label: '名称',
                    enableSearch: true,
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:0px;" : '';
                    },
                    filter: function (item) {
                        return item.level == 2 ? ('<div style="font-size: 14px;font-weight: 600;border-left: 2px solid #faaa33;padding-left: 20px;margin-left: 20px;">' + item.name + '</div>') : '<div style="font-size: 14px;font-weight: 600;' + (item.name == '批量上货导入' ? 'color: red;' : '') + '">' + item.name + '</div>';
                    }
                },
                {
                    name: 'level', label: '层级',
                    filter: function (item) {
                        return item.level;
                    },
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;" : ''
                    }
                },
                {
                    name: 'isShow', label: '状态',
                    filter: function (item) {
                        return item.isShow == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"
                    },
                },
                {
                    name: 'desc1', label: '描述',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },

                {
                    name: 'orderNum', label: '排序号',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
            ],
        },
        'plant-cateogry': { // 植物分类管理
            query: '/category/list?type1=plant-cateogry&size=' + maxSize,//分页查询URL,
            tag: '分类管理',
            dateSearch: false,
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '分类名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入分类名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },

                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'plant-cateogry'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        if ($json.name == '批量上货导入') {
                            return alert('批量上货导入不能修改')
                        }
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改商品分类",
                                data: [
                                    {
                                        type: 'text',
                                        label: '分类名称',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入分类名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        val: $json.desc1 || '',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum || 0,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');

                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=plant-category', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.post('/category/update', {
                            id: $jon.id,
                            level: $jon.level == 1 ? '0' : '1'
                        }, function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                fnSuccess(($jon.level == '1' ? '下架' : '上架') + '操作成功')
                                search({}, true);
                            }
                        });
                    }
                },

            ],
            destroyBtn: function () {
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);

                enableBtn(btns[3], $item);
            },

            fields: [
                {
                    name: 'name', label: '名称',
                    enableSearch: true,
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:0px;" : '';
                    },
                    filter: function (item) {
                        return item.level == 2 ? ('<div style="font-size: 14px;font-weight: 600;border-left: 2px solid #faaa33;padding-left: 20px;margin-left: 20px;">' + item.name + '</div>') : '<div style="font-size: 14px;font-weight: 600;' + (item.name == '批量上货导入' ? 'color: red;' : '') + '">' + item.name + '</div>';
                    }
                },
                {
                    name: 'level', label: '状态',
                    filter: function (item) {
                        // return item.level == 2 ? "background:aliceblue;" : ''
                        return item.level == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"

                    }
                },

                {
                    name: 'desc1', label: '描述',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },

                {
                    name: 'orderNum', label: '排序号',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
            ],
        },
        'plant-variety': { // 植物品类管理
            query: '/category/list?type1=plant-variety&size=' + maxSize,//分页查询URL,
            tag: '品种管理',
            dateSearch: false,
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加品种",
                                data: [
                                    {
                                        type: 'text',
                                        label: '品种名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入品种名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },

                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'plant-variety'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        if ($json.name == '批量上货导入') {
                            return alert('批量上货导入不能修改')
                        }
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改植物品种",
                                data: [
                                    {
                                        type: 'text',
                                        label: '品种名称',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入品种名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '描述',
                                        val: $json.desc1 || '',
                                        placeholder: '请输入描述',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum || 0,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');

                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '上架/下架',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        $.post('/category/update', {
                            id: $jon.id,
                            level: $jon.level == 1 ? '0' : '1'
                        }, function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                fnSuccess(($jon.level == '1' ? '下架' : '上架') + '操作成功')
                                search({}, true);
                            }
                        });
                    }
                },

            ],
            destroyBtn: function () {
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);

                enableBtn(btns[3], $item);
            },

            fields: [
                {
                    name: 'name', label: '名称',
                    enableSearch: true,
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:0px;" : '';
                    },
                    filter: function (item) {
                        return item.level == 2 ? ('<div style="font-size: 14px;font-weight: 600;border-left: 2px solid #faaa33;padding-left: 20px;margin-left: 20px;">' + item.name + '</div>') : '<div style="font-size: 14px;font-weight: 600;' + (item.name == '批量上货导入' ? 'color: red;' : '') + '">' + item.name + '</div>';
                    }
                },
                {
                    name: 'level', label: '状态',
                    filter: function (item) {
                        // return item.level == 2 ? "background:aliceblue;" : ''
                        return item.level == 1 ? "<span class='label label-success'>上架</span>" : "<span class='label label-warning'>下架</span>"

                    }
                },

                {
                    name: 'desc1', label: '描述',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },

                {
                    name: 'orderNum', label: '排序号',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
            ],
        },
        brand: { // 商品品牌
            query: '/category/list?type1=brand',//分页查询URL,
            tag: '分类',
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "添加品牌",
                                data: [
                                    {
                                        type: 'text',
                                        label: '品牌名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '品牌英文名称',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌英文名称',
                                        name: 'en'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '品牌简介',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌简介',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'brand'; // 数据类型菜单
                                    if (!form.name)return alert('请输入品牌名称');
                                    if (!form.en)return alert('请输入品牌英文名称');
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改品牌信息",
                                data: [
                                    {
                                        type: 'text',
                                        label: '品牌名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌名称',
                                        val: $json.name || '',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '品牌英文名称',
                                        val: $json.en || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌英文名称',
                                        name: 'en'
                                    },
                                    {
                                        type: 'textarea',
                                        label: '品牌简介',
                                        val: $json.desc1 || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入品牌简介',
                                        name: 'desc1'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum || 0,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    if (!form.name)return alert('请输入品牌名称');
                                    if (!form.en)return alert('请输入品牌英文名称');
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '海报',
                    class_: 'upload',
                    onClick: function () {
                        var $json = $(this).data('json');
                        var $json = $(this).data('json');
                        uploadFn('品牌海报', {
                            w: 500,
                            h: 400,
                            num: 12,
                            labelNum: 12 + ' upload-custom-label',
                            noCrop: false,
                            preview: 'left-top-preview'
                        }, function (data) {
                            closeLayer(data.layerIndex);
                            $.post('/category/update', {id: $json.id, url: data.path}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess('上传成功～');
                                    search({}, true)
                                } else {
                                    fnFail(res.error || '上传失败！')
                                }
                            })
                            console.log(data);
                        });
                        // window.location.href = './img.html?id=' + $json.id + '&type=theme'
                    }
                },
                {
                    label: '上架/下架',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var status = ($jon.isShow == '1' ? '0' : '1');
                        if (status == '1') {
                            if (!$jon.en || !$jon.desc1 || !$jon.url) {
                                return alert('上架品牌，英文名称、描述、海报任一项都不能为空～')
                            }
                        }
                        var ti = ['targetId=' + $jon.id, 'type1=brand', 'isShow=' + status];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                alert((status == '1' ? '上架' : "下架") + '成功');
                                search({}, true);
                            }
                        })
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[1]);
                disableBtn(btns[2]);
                disableBtn(btns[3]);
                disableBtn(btns[4]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
                enableBtn(btns[4], $item);
            },
            fields: [
                {name: 'name', label: '名称', enableSearch: true,},
                {name: 'en', label: '英文名'},
                {
                    name: 'desc1', label: '描述',
                    filter: function (item) {
                        return viewMore(item.desc1 || ''); // 预览更多内容
                    }
                },
                {name: 'orderNum', label: '排序号'},
                {
                    name: 'isShow', label: '状态',
                    filter: function (item) {
                        return item.isShow == '1' ? '<span class="label label-success">上架</span>' : '<span class="label label-warning">下架</span>'
                    }
                },
                {
                    name: 'url', label: '海报', filter: function (item) {
                    if (item.url) {
                        return '<a target="_blank" href="' + item.url + '" title="点击预览"><img style="height:60px;border-radius: 5px" src="' + item.url + '"></a>'
                    } else {
                        return getDefaultImgStr();
                    }
                }
                },
            ],
        },
        country: { // 商品品牌
            query: '/category/list?type1=country',//分页查询URL,
            tag: '分类',
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "添加发货地",
                                data: [
                                    {
                                        type: 'text',
                                        label: '发货地名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入发货地',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'country'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改发货地信息",
                                data: [
                                    {
                                        type: 'text',
                                        label: '发货地名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入发货地名称',
                                        val: $json.name || '',
                                        name: 'name'
                                    },

                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum || 0,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '国旗',
                    class_: 'upload',
                    onClick: function () {
                        var $json = $(this).data('json');
                        var $json = $(this).data('json');
                        uploadFn('国旗', {
                            w: 300,
                            h: 200,
                            num: 12,
                            labelNum: '12 upload-custom-label',
                            noCrop: false,
                            preview: 'left-top-preview'
                        }, function (data) {
                            closeLayer(data.layerIndex);
                            $.post('/category/update', {id: $json.id, url: data.path}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess('上传成功～');
                                    search({}, true)
                                } else {
                                    fnFail(res.error || '上传失败！')
                                }
                            })
                            console.log(data);
                        });
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[1]);
                disableBtn(btns[2]);
                disableBtn(btns[3]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
                enableBtn(btns[2], $item);
                enableBtn(btns[3], $item);
            },
            fields: [
                {name: 'name', label: '名称', enableSearch: true},
                {name: 'orderNum', label: '排序号'},
                {
                    name: 'url', label: '国旗', filter: function (item) {
                    if (item.url) {
                        return '<img style="height:30px;border-radius: 5px" src="' + item.url + '">'
                    } else {
                        return '未上传';
                    }
                }
                },
            ],
        },
        "kepu-article": {
            query: '/info/queryWithCategory?type1=3&cType=kepu-article',//,
            complexItems: [],
            tag: '分类',
            btns: [
                {
                    label: '新建',
                    onClick: function () {
                        return window.location.href = './edit.html?type=kepu-article'
                    }
                },

                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        return window.location.href = './edit.html?type=kepu-article&id=' + $json.id;
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/info/delete/', {id: $json.id}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '发布<=>草稿',
                    onClick: function () {
                        var $json = $(this).data('json');
                        var label = $json.status == '1' ? '草稿' : ($json.status == '0' ? '发布' : (''));
                        if (confirm('确认' + label + '？')) {
                            $.post('/info/update', {
                                id: $json.id,
                                status: $json.status == '1' ? 0 : '1',
                            }, function (res) {
                                if (res.code == 200) {
                                    fnSuccess(label + '操作成功');
                                    search({}, true);
                                } else {
                                    fnFail(label + '操作失败');
                                }
                            })
                        }
                    }
                },
                {
                    label: '分类编辑',
                    class_: 'btn-info',
                    onClick: function () {
                        window.location.href = './index.html?type=kepu-article-category'
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[1]);
                disableBtn(btns[2]);
                disableBtn(btns[3]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                if ($item.status != 1) { //发布状态不能修改、删除
                    enableBtn(btns[1], $item);
                    enableBtn(btns[2], $item);
                }
                enableBtn(btns[3], $item);
            },
            rendered: function () {
                onClick($('.detail'), function () {
                    var ind = layer.open({
                        type: 2,
                        title: $(this).html(),
                        shadeClose: true,
                        shade: false,
                        maxmin: true, //开启最大化最小化按钮
                        fullScreen: true,
                        content: $(this).data('href')
                    });
                    layer.full(ind);


                })
            },
            fields: [
                {
                    name: 'title', label: '标题', enableSearch: true, filter: function (item) {
                    return '<a  href="javascript:void(0)" class="detail"  data-href="../../product/info/detail.html?noHead=1&id=' + item.id + '">' + item.title + '</a>';
                }
                },
                {name: 'category', label: '分类'},
                {name: 'summary', label: '简介'},
                {
                    name: 'thumbnail', label: '预览图', filter: function (item) {
                    if (!item.thumbnail)return '无';
                    return '<a target="_blank" href="' + item.thumbnail + '" title="点击预览"><img style="height:60px;border-radius: 5px" src="' + item.thumbnail + '"></a>'

                }
                },
                {
                    name: 'createAt', label: '发布时间',
                    filter: function (item) {
                        return formatTime(item.createAt);
                    }
                },
                {
                    name: 'status', _sort: 'status', label: '状态', filter: function (item) {
                    return (item.status == 1 ? '<span class="label label-success">发布</span>' : (item.status == 0 ? '<span class="label label-danger">草稿</span>' : (item.status == 0 ? '删除' : '')) );
                }
                }

            ],
        },
        "kepu-video": {
            query: '/info/queryWithCategory?type1=31&cType=kepu-video',//,
            complexItems: [],//视频内容
            tag: '分类',
            btns: [
                {
                    label: '新建',
                    onClick: function () {
                        return window.location.href = './edit-video.html?type=kepu-video'
                    }
                },

                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        return window.location.href = './edit-video.html?type=kepu-video&id=' + $json.id;
                    }
                },

                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/info/delete/', {id: $json.id}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '发布<=>草稿',
                    onClick: function () {
                        var $json = $(this).data('json');
                        var label = $json.status == '1' ? '草稿' : ($json.status == '0' ? '发布' : (''));
                        if (confirm('确认' + label + '？')) {
                            $.post('/info/update', {
                                id: $json.id,
                                status: $json.status == '1' ? 0 : '1',
                            }, function (res) {
                                if (res.code == 200) {
                                    fnSuccess(label + '操作成功');
                                    search({}, true);
                                } else {
                                    fnFail(label + '操作失败');
                                }
                            })
                        }
                    }
                },
                {
                    label: '分类编辑',
                    class_: 'btn-info',
                    onClick: function () {
                        window.location.href = './index.html?type=kepu-video-category'
                    }
                },
            ],
            destroyBtn: function () {
                disableBtn(btns[1]);
                disableBtn(btns[2]);
                disableBtn(btns[3]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                if ($item.status != 1) { //发布状态不能修改、删除
                    enableBtn(btns[1], $item);
                    enableBtn(btns[2], $item);
                }
                enableBtn(btns[3], $item);
            },
            rendered: function () {
                onClick($('.detail'), function () {
                    var ind = layer.open({
                        type: 2,
                        title: $(this).html(),
                        shadeClose: true,
                        shade: false,
                        maxmin: true, //开启最大化最小化按钮
                        fullScreen: true,
                        content: $(this).data('href')
                    });
                    layer.full(ind);
                })
            },
            fields: [
                {name: 'title', label: '标题', enableSearch: true},
                {name: 'category', label: '分类'},
                {name: 'summary', label: '简介'},
                {
                    name: 'createAt', label: '发布时间',
                    filter: function (item) {
                        return formatTime(item.createAt);
                    }
                },
                {
                    name: 'thumbnail', label: '预览图', filter: function (item) {
                    return '<a target="_blank" href="' + item.video + '" title="点击预览"><img style="height:60px;border-radius: 5px" src="' + item.thumbnail + '"></a>'

                }
                },
                {
                    name: 'status', _sort: 'status', label: '状态', filter: function (item) {
                    return (item.status == 1 ? '<span class="label label-success">发布</span>' : (item.status == 0 ? '<span class="label label-danger">草稿</span>' : (item.status == 0 ? '删除' : '')) );
                }
                }

            ],
        },
        'order-report': { // 商品颜色管理
            query: '/order/report?',//分页查询URL,
            btns: [],
            destroyBtn: function () {
            },
            createBtn: function (_this) {
            },
            fields: [
                {name: 'remark', label: '日期'},
                {name: 'number', label: '商品数量'},
                {name: 'total', label: '总金额'},
                {name: 'percent', label: '总订单量'},
            ],
        },
        permission: {
            query: '/role/getPermission/3?type1=info',//分页查询URL,
            tag: '权限',
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加权限",
                                data: [
                                    {
                                        type: 'text',
                                        label: '权限名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入权限名称',
                                        name: 'permissionName'
                                    },
                                    {
                                        type: 'text',
                                        label: '访问路径',
                                        require: true, // 是否必填
                                        placeholder: '请输入访问路径',
                                        name: 'url'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'remark'
                                    },
                                ],
                                submit: function (form) {
                                    form.type = 1;
                                    $.post('/role/add/permission', form, function (res) {
                                        if (res.code == 0) {
                                            fnSuccess("操作成功,下次登录后生效！");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改权限",
                                data: [
                                    {
                                        type: 'text',
                                        label: '权限名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入权限名称',
                                        val: $json.permissionName,
                                        name: 'permissionName'
                                    },
                                    {
                                        type: 'text',
                                        label: '访问路径',
                                        require: true, // 是否必填
                                        placeholder: '请输入访问路径',
                                        name: 'url',
                                        val: $json.url,
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.remark,
                                        placeholder: '请输入排序号',
                                        name: 'remark',
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id;
                                    $.post('/role/update/permission', form, function (res) {
                                        if (res.code == 0) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                }
            ],

            destroyBtn: function () {
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);
            },
            fields: [
                {name: 'permissionName', label: '权限名称'},
                {name: 'description', label: '描述'},
                {name: 'url', label: 'URL'},
                {name: 'remark', label: '排序号'},
            ],
        },
        msg: {
            query: '/pLetter/list',//分页查询URL,
            tag: '系统消息',
            btns: [
                {
                    label: '标记为已读',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        $.post('/pLetter/update', {id: $json.id, readStatus: 1}, function (res) {
                            if (res.code == 200) {
                                fnSuccess("操作成功");
                                search({}, true);
                            } else {
                                fnFail("操作失败");
                            }
                        })
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm("确认删除?")) {
                            $.post('/pLetter/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess("操作成功");
                                    search({}, true);
                                } else {
                                    fnFail("操作失败");
                                }
                            })
                        }
                    }
                }
            ],
            destroyBtn: function () {
                disableBtn(btns[0]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[0], $item);
                enableBtn(btns[1], $item);
            },
            rendered: function () {
            },
            fields: [
                {
                    name: 'readStatus', label: '状态', filter: function (item) {
                    return item.readStatus == 0 ? '【<a href="javascript:void(0);">未读</a>】' : '【<a href="javascript:void(0);">已读</a>】'
                }
                },
                {name: 'toUser', label: '发件人'},
                {name: 'remark', label: '类型'},
                {name: 'content', label: '内容'},
                {
                    name: 'createAt', label: '时间',
                    filter: function (item) {
                        return formatTime(item.createAt);
                    }
                },
            ],
        },
        ads: {
            query: '/ads/query?type1=0',//分页查询URL,
            tag: '推荐位管理',
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        return window.location.href = './edit.html?type=ads&type1=0';
                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm("确认删除?")) {
                            $.post('/ads/update', {id: $json.id, status: 0}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess("操作成功");
                                    search({}, true);
                                } else {
                                    fnFail("操作失败");
                                }
                            })
                        }
                    }
                },
                {
                    label: '上架',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm("确认上架?")) {
                            $.post('/ads/update', {id: $json.id, status: 1}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess("操作成功");
                                    search({}, true);
                                } else {
                                    fnFail("操作失败");
                                }
                            })
                        }
                    }
                },
                {
                    label: '下架',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm("确认下架?")) {
                            $.post('/ads/update', {id: $json.id, status: 2}, function (res) {
                                if (res.code == 200) {
                                    fnSuccess("操作成功");
                                    search({}, true);
                                } else {
                                    fnFail("操作失败");
                                }
                            })
                        }
                    }
                },
                {
                    label: '修改',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        return window.location.href = './edit.html?type=ads&type1=0&id=' + $json.id;
                    }
                }
            ],
            destroyBtn: function () {
                disableBtn(btns[1]);
                disableBtn(btns[2]);
                disableBtn(btns[3]);
                disableBtn(btns[4]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                if ($item.status == 1) {
                    enableBtn(btns[3], $item);
                }
                if ($item.status == 2) {
                    enableBtn(btns[2], $item);
                }
                enableBtn(btns[1], $item);
                enableBtn(btns[4], $item);
            },
            rendered: function () {
            },
            fields: [
                {
                    name: 'order', label: '排序号',
                },
                {
                    name: 'link', label: '链接',
                    filter: function (item) {
                        return item.link ? '<a target="_blank" href="' + item.link + '">' + item.link + '</a>' : ''
                    }
                },
                {
                    name: 'url', label: '广告',
                    filter: function (item) {
                        return item.url ? '<a target="_blank" href="' + item.url + '">' + item.url + '</a>' : ''
                    }
                },
                {
                    name: 'status', label: '状态',
                    filter: function (item) {
                        return item.status == '1' ? '上架' : '下架'
                    }
                },

            ],
        },
        menu: {
            query: '/category/list?type1=fi&size=150',//分页查询URL,
            tag: '菜单配置',
            btns: [
                {
                    label: '增加',
                    class_: 'create',
                    onClick: function () {
                        var $index = dialogForm(
                            {
                                title: "增加前端菜单",
                                data: [
                                    {
                                        type: 'text',
                                        label: '菜单名称',
                                        require: true, // 是否必填
                                        placeholder: '请输入菜单名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '英文名称',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入英文名称',
                                        name: 'en'
                                    },
                                    {
                                        type: 'text',
                                        label: '访问链接',
                                        val: '',
                                        require: true, // 是否必填
                                        placeholder: '请输入访问链接',
                                        name: 'remark'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: '0',
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 1;
                                    form.type1 = 'front-menu'; // 数据类型菜单
                                    $.post('/category/add', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '修改',
                    class_: 'update',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        var $index = dialogForm(
                            {
                                title: "修改前端菜单",
                                data: [
                                    {
                                        type: 'text',
                                        label: '菜单名称',
                                        val: $json.name,
                                        require: true, // 是否必填
                                        placeholder: '请输入菜单名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '英文名称',
                                        val: $json.en,
                                        require: true, // 是否必填
                                        placeholder: '请输入英文名称',
                                        name: 'en'
                                    },
                                    {
                                        type: 'text',
                                        label: '访问链接',
                                        val: $json.remark || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入访问链接',
                                        name: 'remark'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号',
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.id = $json.id; // 数据类型菜单
                                    //form.type1 = 'front-menu'; // 数据类型菜单
                                    $.post('/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '上传',
                    class_: 'upload',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        window.location.href = './img.html?id=' + $json.id + '&noCrop=1'

                    }
                },
                {
                    label: '删除',
                    class_: 'delete',
                    onClick: function () {
                        var $json = $(this).data('json');
                        console.log($json);
                        if (confirm('确认删除？')) {
                            $.post('/category/delete/' + $json.id, {}, function (res) {
                                if (res.code == 200) {
                                    search({}, true);
                                    fnSuccess('删除成功！');
                                }
                            })
                        }
                    }
                },
                {
                    label: '增加二级菜单',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        if ($jon.level == 2) {
                            $json = $jon;
                        }
                        var $index = dialogForm(
                            {
                                title: "增加二级菜单",
                                data: [
                                    {
                                        type: 'text',
                                        label: '二级菜单名称',
                                        val: $json.name || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入二级菜单名称',
                                        name: 'name'
                                    },
                                    {
                                        type: 'text',
                                        label: '英文名称',
                                        val: $json.en || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入英文名称',
                                        name: 'en'
                                    },
                                    {
                                        type: 'text',
                                        label: '访问链接',
                                        val: $json.remark || '',
                                        require: true, // 是否必填
                                        placeholder: '请输入访问链接',
                                        name: 'remark'
                                    },
                                    {
                                        type: 'text',
                                        label: '排序号' || 0,
                                        val: $json.orderNum,
                                        placeholder: '请输入排序号',
                                        name: 'orderNum'
                                    },
                                ],
                                submit: function (form) {
                                    form.level = 2;
                                    form.type1 = 'front-menu';
                                    if ($jon.level == 1) { //  为一级菜单增加子菜单
                                        form.pId = $jon.id;
                                    } else { // 修改子菜单
                                        form.id = $jon.id; // 数据类型菜单
                                    }
                                    //form.type1 = 'front-menu'; // 数据类型菜单
                                    $.post($jon.level == 1 ? '/category/add' : '/category/update', form, function (res) {
                                        if (res.code == 200) {
                                            fnSuccess("操作成功");
                                            search({}, true);
                                            closeLayer($index);
                                        } else {
                                            fnFail("操作失败");
                                        }
                                    })
                                }
                            });
                    }
                },
                {
                    label: '导航中显示/隐藏',
                    class_: 'update',
                    onClick: function () {
                        var $jon = $(this).data('json');
                        var $json = {};
                        var ti = ['targetId=' + $jon.id, 'type1=category', 'isShow=' + ($jon.isShow == '1' ? '0' : '1')];
                        $.get('/statistic1/set?' + ti.join('&'), function (res) {
                            if (res.code == 200) {
                                console.log('ok!');
                                search({}, true);
                            }
                        })
                    }
                }
            ],
            destroyBtn: function () {
                disableBtn(btns[5]);
                disableBtn(btns[4]);
                disableBtn(btns[3]);
                disableBtn(btns[2]);
                disableBtn(btns[1]);
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
                enableBtn(btns[1], $item);

                if ($item.name != '首页') {
                    enableBtn(btns[5], $item);
                    enableBtn(btns[3], $item);
                    enableBtn(btns[2], $item);
                }

                if ($item.name != '首页' && $item.level == 1 && $item.type1 == 'front-menu') {
                    enableBtn(btns[4], $item);
                }
            },
            listFilter: function (res) {
                console.log(res);
                var t = _.filter(res, function (itme) {
                    return itme.level == 1;
                })
                var tg = _.filter(res, function (itme) {
                    return itme.level == 2;
                });
                tg = _.groupBy(tg, 'pId');
                t = _.sortBy(t, 'orderNum').reverse();
                t1 = [];
                t.map(function (item) {
                    t1.push(item);
                    if (tg[item.id]) { //
                        t1.push(_.sortBy(tg[item.id], 'orderNum').reverse())
                    }
                })
                return _.flatten(t1, true);
            },
            fields: [
                {
                    name: 'name', label: '名称',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:0px;" : ''
                    },
                    filter: function (item) {
                        return item.level == 2 ? ('<div style="border-left: 2px solid #c7c3c3;padding-left: 20px;margin-left: 20px;">' + item.name + '</div>') : item.name;
                    }
                },
                {
                    name: 'level', label: '层级',
                    filter: function (item) {
                        return item.level;
                    },
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
                {
                    name: 'isShow', label: '是否在导航中显示',
                    filter: function (item) {
                        return item.isShow == 1 ? "显示" : '不显示'
                    },
                },
                {
                    name: 'en', label: '英文名',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
                {
                    name: 'desc1', label: '描述',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
                {
                    name: 'orderNum', label: '排序号',
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
                {
                    name: 'url', label: '访问链接',
                    filter: function (item) {
                        if (item.remark) {
                            return '<a target="_blank" href="' + item.remark + '" title="点击预览">' + item.remark + '</a>'
                        } else {
                            return getDefaultImgStr();
                        }
                    },
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },
                {
                    name: 'url', label: '封面图',
                    filter: function (item) {
                        if (item.url) {
                            return '<a target="_blank" href="' + item.url + '" title="点击预览">' + item.url + '</a>'
                        } else {
                            return getDefaultImgStr();
                        }
                    },
                    fnStyle: function (item) {
                        return item.level == 2 ? "background:aliceblue;padding-left:50px;" : ''
                    }
                },

            ],
        },
        comment: {
            query: '/comment/list?type1=device&status=1',//分页查询URL,
            tag: '评选评论',
            btns: [],
            destroyBtn: function () {
            },
            createBtn: function (_this) {
                var $item = $(_this).data('json');
            },
            fields: [
                {
                    name: 'score', label: '评分',
                    filter: function (item) {
                        return (item.score || '0:0:0').split(':').map(function (item, index) {
                            return (index == 0 ? '专业性' : (index == 1 ? '专业性' : '向往性')) + ':' + (item || 0) + ' &nbsp;'
                        }).join('&nbsp;')
                    }
                },
                {
                    name: 'content', label: '评论内容',
                },

                {
                    name: 'userName', label: '评论用户',

                },

                {
                    name: 'create', label: '评论时间',
                    filter: function (item) {
                        return formatTime(item.createAt);
                    }
                }

            ],
        },
    };
    if ($search.type) {
        arg = diff[$search.type];
        if (!arg) {
            return $('.table').html('<p style="text-align: center;line-height: 150px;font-size: 16px;">此功能开发中,敬请期待！</p>');
        }
    }
    var btns = arg.btns.map(function (item) { // 设置分类
        var btn = genBtn(item);
        if (item.onClick) onClick(btn, item.onClick)
        return btn;
    });
    setBtn(btns);


    function search(obj, isForce, isExport) {
        arg.destroyBtn();
        return gSearch({
            table: '.table',
            url: arg.query,
            query: obj,
            isForce: isForce,
            isExport: isExport,
            render: function (res) {
                var _$table = $('.table-responsive .table');
                destroyBtn();
                _$table.$table($.extend(TABLE_SETTING, {
                    checkbox: true, // 是否显示复选框
                    seqNum: true, // 是否显示序号
                    sort: search, //排序回调函数
                    destroyBtn: arg.destroyBtn, //禁用按钮
                    createBtn: arg.createBtn, // 启用她扭
                    toolbar: '.toolbar',
                    enableSetting: true,//允许自定义显示列
                    // rendered:function(){
                    //    
                    // },
                    search: search,
                    showSearchComplex: true,
                    rendered: arg.rendered || function () {
                    },
                    fields: arg.fields,
                    data: arg.listFilter ? arg.listFilter(res) : res || [],
                }, arg.dateSearch ? { // 允许日期区间搜索
                    complexItems: [
                        {label: "", name: 'date', dateRange: true},
                    ]
                } : {}));
            }
        }, obj.first ? false : true);
    }

    search({}, true);
})

